var express = require('express');

var router = express.Router();
var mysql = require("mysql");
var baseDate = require('./mysql.js');



router.get('/', function(req, res, next) {
    return  res.render('buy.html');

});
router.post('/list', function(req, res, next) {
   
    var  u = req.body.uname;
    var p = req.body.upwd;
    console.log(req.body);
    var $sql = mysql.createConnection(baseDate.mysql);
    $sql.connect();
    var select = "select * from users where uname = '"+u+"' and pwd = '"+p+"'";   
    return  $sql.query(select,function(err,result){   
        console.log(result)
       if(result.length !=0){
                
                res.send({ok:true,msg:"d"});
            }else {
               
                res.send({ok:false,msg:"用户名不存在或密码错误"});
            }
        
    

});

})

module.exports = router;